	//Added by Bhaskar on 25 sep 2003
	function checkPartLocationLot()
	{
		var errors = '';
		var pa = document.getElementById("errors");
		var procStepId = document.boardInventorydataentryform.processStepId.value;
		var locId = document.boardInventorydataentryform.locationId.value;
		var lotId = document.boardInventorydataentryform.lotNo.value;
		if ( procStepId == '0' ) 
		{
			pa.innerHTML = "<li> Please select a valid Part Number " ;
			document.boardInventorydataentryform.processStepId.focus();
			return false;
		}
		if (locId == '0')
		{
			pa.innerHTML = "<li>Please select a valid Location";
			document.boardInventorydataentryform.locationId.focus();
			return false;
		}
		if (lotId == '0')
		{
			pa.innerHTML = "<li>Please select a valid Lot ";
			document.boardInventorydataentryform.lotNo.focus();
			return false;
		}
		return true;
	}


    function validateDate ( dateIn )
    {
        var pa = document.getElementById ( "errors" );
		pa.innerHTML = '';
        if ( dateIn == '' || dateIn == null )
        {
            pa.innerHTML = "<li> Please enter a Date in the DateIn field";
            return false;
        }
        else
        {
			if ( !chkDate ( dateIn, 'Date In', 'Y' ) )
			{
                pa.innerHTML = "<li> Please enter a valid DateIn, Date must be in mm/dd/yyyy format";
                return false;
            }
            else
			{
                return true;
            }
        }
    }


	function validateLotNumber()
	{
		var errors = "";
		var bool = true;
		var pa	= document.getElementById("errors");
		var form = document.boardInventorydataentryform;
		pa.innerHTML = errors;
		var insertingNewLotNumber = form.newLotNumber;
        if ( insertingNewLotNumber.length == null )
		{
		    if( form.newLotNumber.value.indexOf("'") != "-1" )
            {
                errors = "<li>Single quotation is not acceptable in Lot Number</li>";
                pa.innerHTML = errors;
                insertingNewLotNumber.focus();
                return false;
            }
			if( parseInt ( insertingNewLotNumber.value.trim().length ) == 0 )
			{
				errors = "<li> Please enter a value for Lot Number";
				pa.innerHTML = errors;
				insertingNewLotNumber.focus();
				bool = false;
			}
			else
			{
				if ( form.lotNo.value == '-1' )
				{
					bool = checkLotNumber ( insertingNewLotNumber.value );
					if ( !bool )
					{
						errors = '<li> Lot Number '+insertingNewLotNumber.value+' already exists';
						pa.innerHTML = errors;
						insertingNewLotNumber.focus();
					}
				}
				else
				{
					//develop a new logic for updation based lot number check.
					//But a check is already present in Action class.
				}
			}
		}
		else
		{
			/*
			This tempBool and extra for loop are defined only to check the user from
			entering all blank lot numbers and not to mess up with the main logic
			Bhaskar on 25 Feb 2004
			*/
			var tempBool = false;
			for ( var zz = 0; zz < insertingNewLotNumber.length; zz++ )
			{
				if ( parseInt ( insertingNewLotNumber[zz].value.trim().length ) > 0 )
				{
					tempBool = true;
				}
			}

			for ( var j = 0; j < insertingNewLotNumber.length; j++ )
			{
			    if( insertingNewLotNumber[j].value.indexOf("'") != "-1" )
                {
                    errors = "<li>Single quotation is not acceptable in Lot Number</li>";
                    pa.innerHTML = errors;
                    insertingNewLotNumber[j].focus();
                    return false;
                }
				if ( parseInt ( insertingNewLotNumber[j].value.trim().length) > 0 )
				{
					if ( form.lotNo.value == '-1' )
					{
						bool = checkLotNumber ( insertingNewLotNumber[j].value );
						if ( !bool )
						{
							errors = '<li> Lot Number '+insertingNewLotNumber[j].value+' already exists';
							pa.innerHTML = errors;
							insertingNewLotNumber[j].focus();
							return bool;
						}
					}

				}
				for ( var g = 0; g < insertingNewLotNumber.length; g++ )
				{
					if (g > j)
					{
						if ( parseInt ( insertingNewLotNumber[j].value.trim().length ) > 0  && parseInt ( insertingNewLotNumber[g].value.trim().length ) > 0 )
						{
							if ( insertingNewLotNumber[j].value == insertingNewLotNumber[g].value )
							{
								errors = "<li> Duplicate lot numbers are not allowed";
								pa.innerHTML = errors;
								insertingNewLotNumber[g].focus();
								bool = false;
								return bool;
							}
						}
					}
				}
			}
		}
		if ( tempBool == false )
		{
			bool = false;
			insertingNewLotNumber[0].focus();
			pa.innerHTML = '<li>Please enter atleast one Lot Number';
		}
		return bool;
	}


	function checkLotNumber( lotNumber )
	{
		var p1 = -1;
		var p2 = -1;
		var lotName = '';
		var flag = true;
		var lotNoVar = document.boardInventorydataentryform.lotNo;
		for ( var count =0; count < lotNoVar.length; count++ )
		{
			if ( ( lotNoVar[count] != '0' ) || ( lotNoVar[count] != '-1' ) )
			{
				p1 = document.boardInventorydataentryform.lotNo[count].value.indexOf('$')+1;
				p2 = document.boardInventorydataentryform.lotNo[count].value.lastIndexOf('$');
				lotName = document.boardInventorydataentryform.lotNo[count].value.substring(p1, p2).trim();
				if ( lotName.toUpperCase() == lotNumber.trim().toUpperCase() )
				{
					flag = false;
					break;
				}
			}
		}
		return flag;
	}


	function validateQtyInTestQtyRejQty( test, reje, qyIn, pa )
	{
		test.value = test.value.trim();
		reje.value = reje.value.trim();
		qyIn.value = qyIn.value.trim();
		if ( checkInteger ( qyIn.value.trim(), ' Un tested Qty ', 'Y' ) == false )
		{
			qyIn.focus();
			pa.innerHTML = "<li>"+errMsg;
			return false;
		}
		if ( parseInt ( qyIn.value.trim() ) < 1 )
		{
			qyIn.focus();
			pa.innerHTML = "<li> Un tested Qty cannot be negative Number or Zero"
			return false;
		}

        if ( ( parseInt ( test.value.trim().length ) > 0 ) && checkInteger ( test.value.trim(), ' Good Qty', 'Y' ) == false )
		{
			test.focus();
			pa.innerHTML = "<li>"+errMsg;
			return false;
		}
		if ( ( parseInt ( reje.value.trim().length ) > 0 ) && checkInteger ( reje.value.trim(), ' Rejected Qty', 'Y' ) == false )
		{
			reje.focus();
			pa.innerHTML = "<li>"+errMsg;
			return false;
		}

		//untestedQty should not less than ( goodQty+rejectedQty )

		var totGoodRejQty = 0;
		if ( parseInt ( test.value.trim().length ) > 0 )
		{
		     totGoodRejQty = totGoodRejQty + parseInt ( test.value.trim(), 10 )
		}
		if ( parseInt ( reje.value.trim().length ) > 0 )
		{
		     totGoodRejQty = totGoodRejQty + parseInt ( reje.value.trim(), 10 )
		}

		if ( parseInt ( qyIn.value.trim(), 10 ) < totGoodRejQty )
		{
		    test.focus();
		    pa.innerHTML = "<li>Un tested Qty should not be less than (Good Qty+Rejected Qty) ";
			return false;
		}
		return true;
	}



	function enableRejectedQtyFields()
	{
		if ( document.boardInventorydataentryform.rejectedQuantity.length == null )
		{
			document.boardInventorydataentryform.rejectedQuantity.disabled = false;
		}
		else
		{
			var rowCount = document.boardInventorydataentryform.rejectedQuantity.length;
			for ( var count = 0; count < rowCount; count++)
			{
				document.boardInventorydataentryform.rejectedQuantity[count].disabled = false;
			}
		}
	}


    /*function selectType()
    {
        document.boardInventorydataentryform.action="<%=chipTracContext%>/boardInventoryDataEntry.do?action=type";
        document.boardInventorydataentryform.submit();
    }*/

    /*function confirm()
	{
	    if(document.boardInventorydataentryform.clarify[0].checked)
		{
            document.boardInventorydataentryform.action="<%=chipTracContext%>/boardInventoryDataEntry.do?action=lotnumber";
            document.boardInventorydataentryform.submit();
        }
        else
		{
            return ;
        }
    }*/

	/*function validateQty(){
		var errors = "";
		var pa	= document.getElementById("message");
		var insertingQuantityIn	= document.boardInventorydataentryform.insertingQuantityIn;
		/ *
		if ( checkInteger ( form.grossDice.value, 'Gross Dice', 'Y' ) == false )

		* /

		if(insertingQuantityIn.length == null)
		{
			if((insertingQuantityIn.value == null) || (insertingQuantityIn.value == '')){
				//alert("This is check");
				errors = "<li> Please enter Quantity";
				pa.innerHTML = errors;
				insertingQuantityIn.focus();
				return false;
			}
			if ( checkInteger ( insertingQuantityIn.value, 'Quantity', 'Y' ) == false )
			{
				//if (!isInteger(insertingQuantityIn.value)){
				pa.innerHTML = errMsg;
				insertingQuantityIn.focus();
				return false;
			}
		}
		else
		{
			for (var j =0;j<insertingQuantityIn.length;j++){
				//alert(insertingQuantityIn[j].value);
				if (insertingQuantityIn[j].value == '')  {
					//errors = "please insert";
					pa.innerHTML = "<li> Please enter the quanitity";
					insertingQuantityIn[j].focus();
					return false;
				}
				if ( checkInteger ( insertingQuantityIn[j].value, 'Quantity', 'Y' ) == false )
				{
					//if (!isInteger(insertingQuantityIn.value)){
					pa.innerHTML = errMsg;
					insertingQuantityIn[j].focus();
					return false;
				}
			}
		}
		return true;
	}*/

 function enableFields()
 {
    if ( document.boardInventorydataentryform.insertingQuantityIn.length == null )
    {
        document.boardInventorydataentryform.insertingQuantityIn.disabled = false;
    }
    else
    {
        var rowCount = document.boardInventorydataentryform.insertingQuantityIn.length;
        for ( var count = 0; count < rowCount; count++)
        {
            document.boardInventorydataentryform.insertingQuantityIn[count].disabled = false;
        }
    }
 }